package com.atguigu.edu.realtime.util;

public class MySqlUtil {
    //获取从mysql中读取字典表数据创建FlinkSQL的动态表DDL操作MySql工具类
    public static String getBaseSourceLookUpDDL() {
        return "CREATE TABLE base_source (\n" +
                "  id  STRING,\n" +
                "  source_site STRING,\n" +
                "  source_url STRING,\n" +
                "  PRIMARY KEY (dic_code) NOT ENFORCED\n" +
                ") " + getJdbcDDL("base_source");
    }

    //获取jdbc连接器相关连接属性
    public static String getJdbcDDL(String tableName) {
        return " WITH (\n" +
                "   'connector' = 'jdbc',\n" +
                "   'driver' = 'com.mysql.cj.jdbc.Driver',\n" +
                "   'url' = 'jdbc:mysql://hadoop101:3306/edu',\n" +
                "   'table-name' = '" + tableName + "',\n" +
                "   'lookup.cache.max-rows' = '200',\n" +
                "   'lookup.cache.ttl' = '1 hour',\n" +
                "   'username' = 'root',\n" +
                "   'password' = '000000'\n" +
                ")";
    }
}